<?php

namespace App\Models\Factory;

use App\Helpers\DateUtils;
use App\Helpers\Http\HttpClient;
use App\Helpers\Utils;
use App\Models\AbsModelFactory;
use App\Models\Orm\Sign;
use App\Models\Orm\SmsConfig;
use App\Models\Orm\SystemConfig;
use App\Strategies\SmsStrategy;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;

/**
 * 短信工厂
 * Class SmsFactory
 * @package App\Models\Factory
 */
class SignFactory extends AbsModelFactory
{
    public static function addSign($user_id)
    {
        $data['user_id'] = $user_id;
        $data['stime'] = DateUtils::getToday();
        $data['days'] = 1;
        $result = Sign::create($data);

        return $result ? true : false;

    }

    public static function updateSign($user_id,$days)
    {
        $data['user_id'] = $user_id;
        $data['stime'] = DateUtils::getToday();
        $data['days'] = $days;
        $result = Sign::where('user_id',$user_id)->update($data);
        return $result ? true : false;

    }


    public static function editSign($user_id)
    {

        $sign = Sign::where('user_id',$user_id)->first();
        $sign -> days += 1;
        $sign -> stime = DateUtils::getToday();
        $result = $sign ->save();
        return $result ? $sign -> days += 1 : false;

    }


}